<style>
    .layui-form-label {
        float: left;
        display: block;
        padding: 9px 15px;
        width: 120PX;
        font-weight: 400;
        line-height: 20px;
        text-align: right;
    }
    .layui-input-block {
        margin-left: 150px;
        min-height: 36px;
    }
</style>
<div class="layui-fluid layui-anim website-anim-up" id="website-class-checkMember" lay-title="组成员变更审核">
    <div class="layui-row layui-col-space8 website-container">
        <div class="layui-col-md12 layui-col-sm12 layui-col-xs12">
            <form class="layui-form" lay-filter="class-apply-add-form">
                <input type="hidden" id="declareId" name="declareId" th:value="${declareId}">
                <div class="layui-card" id="client-user-info">
                    <div class="layui-card-body layui-form-item">
                        <div class="layui-row">
                            <div class="layui-inline layui-col-md6">
                                <label class="layui-form-label layui-form-label">主持人原单位</label>
                                <div class="layui-input-block">
                                    <input type="text" disabled th:value="${appCompany}" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline layui-col-md6">
                                <label class="layui-form-label layui-form-label">申请修改单位</label>
                                <div class="layui-input-block">
                                    <input type="text" disabled name="changeCompany" th:value="${updateCompany}" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <table lay-filter="memberDetail" lay-data="{id: 'memberDetail'}"></table>
                        </div>
                        <div class="layui-row">
                            <label class="layui-form-label website-form-item-require">审核结果</label>
                            <div class="layui-input-block">
                                <input type="radio" name="statusTypeCode" lay-filter="applyRadio" value="change_passed" title="通过" checked="">
                                <input type="radio" name="statusTypeCode" lay-filter="applyRadio" value="change_failed" title="不通过">
                            </div>
                        </div>
                        <div class="layui-row" id="checkResult">
                            <div class="layui-inline layui-col-md12">
                                <label class="layui-form-label website-form-item-require">审核不通过的原因</label>
                                <div class="layui-input-block">
                                    <textarea id="titleResult" class="layui-textarea" name="checkResult" placeholder="请输入内容，限制 500 字" autocomplete="off"></textarea>
                                </div>
                            </div>
                        </div>
                        <div class="layui-card-footer">
                            <button type="submit" class="layui-btn" lay-submit="" lay-filter="checkMember">审核提交</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/html" id="operation-code">
    {{#
    var dict=layui.dict.getByCode(d.operationCode);
    }}
    {{#  if(dict){ }}
    <span>{{ dict.name }}</span>
    {{#  } }}
</script>
<script type="text/html" id="sex-type">
    {{#
    var dict=layui.dict.getByCode(d.sexTypeCode);
    }}
    {{#  if(dict){ }}
    <span>{{ dict.name }}</span>
    {{#  } }}
</script>
<script type="text/html" id="position-type">
    {{#
    var dict=layui.dict.getByCode(d.positionTypeCode);
    }}
    {{#  if(dict){ }}
    <span>{{ dict.name }}</span>
    {{#  } }}
</script>
<script type="text/html" id="title-type">
    {{#
    var dict=layui.dict.getByCode(d.titleTypeCode);
    }}
    {{#  if(dict){ }}
    <span>{{ dict.name }}</span>
    {{#  } }}
</script>
<script type="text/html" id="degree-type">
    {{#
    var dict=layui.dict.getByCode(d.degreeTypeCode);
    }}
    {{#  if(dict){ }}
    <span>{{ dict.name }}</span>
    {{#  } }}
</script>
<script data-th-inline="none" type="text/javascript">
    layui.use(['jquery', 'form', 'table', 'website' ], function () {
        var $ = layui.jquery,
                website = layui.website,
                $view = $('#website-class-checkMember'),
                form = layui.form,
                table = layui.table,
                sortObject = {field: 'createTime', type: null},
                tableIns;
        form.render();
        initTable();
        $("#checkResult").css("display", "none");
        form.on('submit(checkMember)', function(data){
            if(data.field.statusTypeCode=='change_failed'&& (data.field.checkResult==""||data.field.checkResult==null)){
                website.alert.error('审核不通过的原因不能为空');
                return false;
            }
            website.post(ctx + 'declareEntrust/checkChange/commit', data.field, function () {
                layer.closeAll();
                website.alert.success('操作成功');
                $('#website-declareEntrust').find('#query').click();
            });
            return false;
        });
        form.on('radio(applyRadio)', function(data){
            if(data.value == 'change_failed'){
                $("#checkResult").css("display", "block");

            } else {
                $("#checkResult").css("display", "none");
                $("#titleResult").val("");
            }
        });
        function initTable() {
            tableIns = website.table.init({
                elem: $view.find('table'),
                id: 'memberDetail'
                ,limit: 10 //注意：请务必确保 limit 参数（默认：10）是与你服务端限定的数据条数一致
                , url: ctx + 'memberUpdate/list'
                ,cols: [[
                    {type: 'numbers', title: '序号'},
                    {field: 'name', title: '姓名'},
                    {title: '操作类型',templet: '#operation-code'},
                    {field: 'identity', title: '证件号'},
                    {templet: '#sex-type', title: '性别'},
                    {field: 'birthday', title: '出生日期'},
                    {title: '职务', templet: '#position-type'},
                    {title: '职称级别', templet: '#title-type'},
                    {title: '职称', field: 'professionCode'},
                    {templet: '#degree-type',title: '最终学位'},
                    {field: 'field', title: '研究领域'},
                    {field: 'companyAddress', title: '工作单位'},
                    {field: 'mobile', title: '联系电话'},
                    {field: 'email', title: '电子邮箱'}
                ]],
                where : {
                    declareId : $("#declareId").val(),
                }
            });
        }
    })
</script>